﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Acando.Dynamics.CRM.Silverlight.Library.Interfaces;
using System.Windows.Data;
using Acando.Dynamics.CRM.Silverlight.Library.Converter;
//using Acando.Dynamics.CRM.Silverlight.Library.CrmProxyWcf;
using Acando.Dynamics.CRM.Silverlight.Library.CrmSdk;

namespace Acando.Dynamics.CRM.Silverlight.Library.Controls.FieldControls
{
    public class BaseValueControl : UserControl
    {
        protected String ControlType { get; private set; }
        protected String FieldName { get; private set; }
        protected IRecordControl RecordControl { get; private set; }

        private BaseValueControl()
        {

        }

        public BaseValueControl(IRecordControl recordControl ,string controlType, string fieldName)
        {
            this.ControlType = controlType;
            this.FieldName = fieldName;
            this.RecordControl = recordControl;
        }
               
        protected Binding GetBinding(IRecordControl recordControl, string controlType, string fieldName)
        { 
            //var test = new Binding(
            return new Binding("Properties")
            {
                Mode = BindingMode.TwoWay,
                Converter = new CrmPropertyConverter(fieldName,
                                                     recordControl.Entity as DynamicEntity),
                ConverterParameter = controlType
            };
        }
    }
}
